#include <stdrw.h>
#include "stack.h"
#define push stack_push
#define pop stack_pop
stack a;
int n,m;
int main(void){
    int x,i;
    freopen("stack.in","r",stdin);
    freopen("stack.out","w",stdout);
    scanf("%d%d",&n,&m);
    while (n--){
          read(&x);
          push(&a,x);
    }
    while (m--){
          read(&x);
          if (x<0)
             pop(&a,-x);
          else
              push(&a,x);
    }
    for (i=0;i<a.top();++i)
        printf("%d ",a.val[i]);
    return 0;
}
